#ifndef __ALLOCATOR_H__
#define __ALLOCATOR_H__

class IAllocator{
	virtual char* alloc(int size) = 0;
	virtual void free() = 0;
};

template<int SIZE>
class AllocatorImpl : public IAllocator{
private:
	char buffer[SIZE];
	size_t pos_;
public:
	AllocatorImpl() : pos_(0) {}

	virtual char* alloc(int size){
		char* buf = &buffer[pos_];
		pos_ += size;
		return buf;
	}
	virtual void free(){
		pos_ = 0;
	}
};

/*

class AllocatorT{
private:
	IAllocator& allocator;
public:
	AllocatorT(IAllocator&){}

	template<typename T>
	T* alloc(){
		T* t = new(&buffer[pos_]) T;
		pos_ += sizeof(T);
		return t;
	}
	//T** allocArray(int size){
	//	T** t = new(&buffer[pos_]) (T*);
	//	pos_ += sizeof(T*);
	//	for(int i = 0; i < size; ++i){
	//		t[i]=alloc<T>();
	//	}
	//	return t;
	//}
	template<typename T>
	void free(T* t){
		t->~T();
		pos_=0;
	}
};*/
#endif